﻿using System.Collections.Generic;
using UnityEngine;
/*做一个类似于选项的功能*/
public class OnMouseTest_02 : MonoBehaviour
{
    private void OnMouseDown()
    {
        if (gameObject.GetComponent<MeshRenderer>().material.color == Color.white)
        {
            GameObject[] cubes = GameObject.FindGameObjectsWithTag("a");
            for (int i = 0; i < cubes.Length; i++)
            {
                cubes[i].GetComponent<MeshRenderer>().material.color = Color.white;
            }
            this.gameObject.GetComponent<MeshRenderer>().material.color = Color.red;
        }
        else
        {
            gameObject.GetComponent<MeshRenderer>().material.color = Color.white;
        }
    }
}
